#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) Huoty, All rights reserved
# Author: Huoty <sudohuoty@163.com>
# CreateTime: 2024-04-23 13:02:47

import os
import time
import threading


lock = threading.Lock()

def func1():
    while True:
        with lock:
            time.sleep(0.5)


def func2():
    while True:
        with lock:
            time.sleep(0.1)


def main():
    thread1 = threading.Thread(target=func1)
    thread1.setDaemon(True)
    thread1.start()

    thread2 = threading.Thread(target=func1)
    thread2.setDaemon(True)
    thread2.start()

    print("PID: {}".format(os.getpid()))
    while True:
        time.sleep(10)


if __name__ == "__main__":
    main()
